home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Determining the length of an int in string form
- Date: Mon, 25 Mar 96 12:48:09 GMT
- Organization: none
- Message-ID: <827758089snz@genesis.demon.co.uk>
- References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net> <4in1ga$ogk@airdmhor.gen.nz> <Pine.SOL.3.91.960319172332.4535A-100000@darwin.UCSC.EDU> <314F65D3.6A8@oc.com> <827703345snz@genesis.demon.co.uk> <3155E067.3261@iadfw.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <3155E067.3261@iadfw.net> lfw@iadfw.net "Larry Weiss" writes:
-
- >We all discussed this, maybe a year ago, and what I was remembering was
- >the issue with the representation of end-of-line on the file system, and
- >whether this affected the return value of fprintf().
-
- 7.9.3:
-
- "All input takes place as if characters were read by successive calls to
- the fgetc function; all output takes place as if characters were written
- by successive calls to the fputc function."
-
- The only figure with any meaning is the number of effective calls to fputc.
- Once you start getting into the lower level text file line formatting C
- ceases to ascribe any meaningful values to 'characters transferred'. So
- IMHO the return value of fprintf can only refer to the number of effective
- fputc calls which means '\n' always corresponds to precisely 1 character.
-
- >Seems safe enough
- >that if you never indicate the end-of-line condition (usually via the
- >\n in in format string) then that is not an issue (even on a mainframe,
- >with those block-mode fixed-length records).
-
- The problem there is that in block-mode fixed-length records you may well
- get *no* characters written until the whole block is assembled (i.e. you
- wrote a '\n'). Perhaps a more obvious format to show this is a variable
- length block with the block length written at the start: nothing can be
- written until the block length is known.
-
- >Now what I'd really like to see in the next revision of the standard library
- >would be an snprintf() with the extra argument to declare only so many
- > writeable
- >chars in the buffer, and a return code to indicate logical attempts to write
- >beyond that limit.
-
- Indeed, a return value indicating how many characters would have been
- written to the buffer if it were large enough.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-